package rebot

//import "time"
import "gorm.io/gorm"
import "go_part/utils"
//import "fmt"

type LimitBasic struct{
	gorm.Model
	Name string
	LevelLocalID string
	CompanyID string
	Phone string 
	Email string 
	LimitID string
	Descript string
 }

 func (table *LimitBasic) TableName() string {

	return "limit_action_basic"
}

func GetLimitBasicList() []*LimitBasic { 
	data := make([]*LimitBasic,10)
	utils.DB.Find(&data)
	// for _,v : = range data {
	// 	fmt.Println(v)
	// }
	return data
}

func FindLimitBasicByName(name string) LimitBasic {
	user := LimitBasic{}
	utils.DB.Where("name = ?",name).Find(&user)
	return user
}

func FindLimitBasicByID(id uint) LimitBasic {
	user := LimitBasic{}
	utils.DB.Where("id = ?",id).First(&user)
	return user
}

func FindLimitBasicByTypeIDAndCompanyID(id string,CompanyID string) []*LimitBasic {
	user := make([]*LimitBasic,100)
	utils.DB.Where("level_local_id = ? and company_id = ?",id,CompanyID).Find(&user)
	return user
}

func CreateLimitBasic(user LimitBasic) *gorm.DB {
	
	return utils.DB.Create(&user)
}

func DeleteLimitBasic(user LimitBasic) *gorm.DB {
	
	return utils.DB.Delete(&user)
}

func UpdateLimitBasic(user LimitBasic) *gorm.DB {
	
	return utils.DB.Model(&user).Updates(LimitBasic{ Descript: user.Descript})
}